Option Strict Off
Option Explicit On
Module MODpreferences
	Private fso As Scripting.FileSystemObject
	Private prefsFile As Scripting.TextStream
	
	Public Function getPref(ByRef relativePath As String, ByRef preference As String) As Object
		
		On Error Resume Next
		
		If relativePath <> "" Then relativePath = "\" & relativePath
		With New regOp
			.Root = regOp.RegRoot.HKEY_LOCAL_MACHINE
			.Key = "Software\bbd\AccessSearch\preferences" & relativePath
			'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object getPref. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			getPref = .Value(preference)
		End With
		
	End Function
	
	Public Function setPref(ByRef relativePath As String, ByRef preference As String, ByRef Value As Object) As Object
		
		On Error Resume Next
		
		If relativePath <> "" Then relativePath = "\" & relativePath
		
		With New regOp
			.Root = regOp.RegRoot.HKEY_LOCAL_MACHINE
			.Key = "Software\bbd\AccessSearch\preferences" & relativePath
			'UPGRADE_WARNING: Couldn't resolve default property of object Value. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.Value(preference) = Value
		End With
		
	End Function
	
	Public Function saveColumnWidths() As Object
		Dim header As Object
		Dim i As Object
		Dim strColumnWidths As Object
		
		On Error Resume Next
		
		'UPGRADE_WARNING: Couldn't resolve default property of object strColumnWidths. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		strColumnWidths = ""
		'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		i = 0
		For	Each header In FRMmain.DataGrid.Columns
			'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			i = i + 1
			'UPGRADE_WARNING: Couldn't resolve default property of object header.Width. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object strColumnWidths. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			strColumnWidths = strColumnWidths & header.Width & ","
		Next header
		'UPGRADE_WARNING: Couldn't resolve default property of object i. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		If i > 0 Then
			'UPGRADE_WARNING: Couldn't resolve default property of object strColumnWidths. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			strColumnWidths = Left(strColumnWidths, Len(strColumnWidths) - 1)
			setPref("", "columnWidths", strColumnWidths)
			DLGpreferences.Hide()
		Else
			MsgBox("There Are Currently No Columns" & vbCrLf & "You Must First Open A Database File")
		End If
	End Function
	
	
	Public Sub setDefaultPrefs()
		
		On Error Resume Next
		
		With New regOp
			
			.Root = regOp.RegRoot.HKEY_LOCAL_MACHINE
			.Key = "Software\bbd\AccessSearch"
			
			'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(version). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			If .Value("version") <> "4.2" Then
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("version") = "4.2"
				.Key = "Software\bbd\AccessSearch\preferences"
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("columnWidths") = ""
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("defaultDatabasePath") = My.Application.Info.DirectoryPath & "\localStock.mdb"
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("defaultSearchField") = "partNumber"
				.Key = "Software\bbd\AccessSearch\preferences\remoteDB"
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("autoUpdate") = 1
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("fieldNames") = "partNumber,quantity,remark,manufacturer,dateCode,userComment"
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("serverAddress") = "example : http://SERVER_ADDRESS"
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("updatePagePath") = "example : FOLDER(s)/PAGE_NAME"
				'UPGRADE_WARNING: Couldn't resolve default property of object New (regOp).Value(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Value("databaseName") = "webStock.mdb"
			End If
			
		End With
	End Sub
	'----------------
	'   NOT USED    '
	'----------------
	'Public Function getPreference(fileName As String, preference As String)
	'    Set fso = New Scripting.FileSystemObject
	'
	'    prefsFilePath = App.Path & "\preferences\" & fileName
	'
	'    If Not fso.FolderExists(App.Path & "\preferences") Then
	'        MsgBox "An error occured while trying to load a preference" & vbCrLf & _
	''            "There is no ""preferences"" folder in the application directory"
	'        Exit Function
	'    End If
	'
	'    If Not fso.FileExists(prefsFilePath) Then
	'        MsgBox "An error occured while trying to load a preference" & vbCrLf & _
	''            "The preference file """ & fileName & """ was not found"
	'        Exit Function
	'    End If
	'
	'    Set prefsFile = fso.OpenTextFile(prefsFilePath, ForReading, False)
	'
	'    Do Until prefsFile.AtEndOfStream
	'        line = Trim(prefsFile.ReadLine)
	'        If Not Left(line, 2) = "//" Then
	'            equalSignPosition = InStr(line, "=")
	'            prefName = Left(line, equalSignPosition - 1)
	'            If preference = prefName Then
	'                prefValue = Mid(line, equalSignPosition + 1)
	'                getPreference = prefValue
	'            End If
	'        End If
	'    Loop
	'
	'End Function
End Module